PP=cpp
PPopt=-nostdinc -P
BinDir=../bin

.PHONY: all clean CheckBinDir Compiler0.1 Compiler0.2

all: clean CheckBinDir Compiler0.2

CheckBinDir:
	mkdir -p $(BinDir)

Compiler0.1:
	$(PP) $(PPopt) -o $(BinDir)/Compiler0.1.js Compiler0.1/Main.js
	touch $(BinDir)/Compiler0.1.js.tmp
	sed -f Compiler0.1/CleanupPatterns.txt $(BinDir)/Compiler0.1.js > $(BinDir)/Compiler0.1.js.tmp
	mv $(BinDir)/Compiler0.1.js.tmp $(BinDir)/Compiler0.1.js

Compiler0.2: Compiler0.1
	js $(BinDir)/Compiler0.1.js Compiler0.2/Compiler.ojsproj

clean:
	rm -rf $(BinDir)/*

